#!/bin/sh

myDir=`dirname $0`
echo $myDir
cd $myDir

myBuildVersion=`grep "packageVersion =" ./src/releaseinformation.cpp | cut -d "\"" -f 2 | cut -d "-" -f 1`
echo Building $myBuildVersion

targetName="push-it-$myBuildVersion"
cd rpmBuild/
sed -e " s/Version: .*/Version: $myBuildVersion/g " -e " s/Source: .*/Source: push-it-$myBuildVersion.tar.gz/g " spec > $targetName.spec
rm -rf $targetName
mkdir $targetName
cd -
cp -r src/ rpmBuild/$targetName/
cd rpmBuild/$targetName
# /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++-64 -unix -o Makefile ./src/push-it.pro
cd ..
cp TODO INSTALL COPYING README $targetName/
cp ../debianFiles/changelog $targetName/
tar -zcf $targetName.tar.gz $targetName/
cp $targetName.tar.gz ~/rpm/SOURCES/
cp $targetName.spec ~/rpm/SPECS/
rpmbuild -ba $targetName.spec

exit 0
